#ifndef NAMEDDATABASE_H_
#define NAMEDDATABASE_H_

#include <f32file.h>
#include <d32dbms.h> 

//database name
_LIT(KtxDatabaseName,"c:\\DATA\\Logs.db");
// Table column names
_LIT(NCol0,"Index");
_LIT(NCol1,"MyNumber");		// My Phone Number
_LIT(NCol2,"RemoteNumber");	// Phone number of Remote party
_LIT(NCol3,"StartTime");	// Format: hh:mm:ss
_LIT(NCol4,"Direction");	// whether Incoming="0" OR Outgoing="1"
_LIT(NCol5,"Type");			// whether Voice="0" OR Video="1"
_LIT(NCol6,"Duration");		// Duration in seconds. Datatype: EDbColUint32
_LIT(NCol7,"Date");			// Format: yyyy/MM/dd
 
// database table name
_LIT(KtxtLogTable,"Logs");
 
class TExampleItem
{
    public:
        TExampleItem(): iIndex(-1){};
    public:
        TInt 		iIndex;
        TBuf<100> 	iMyNumber; 
        TBuf<100>	iRemoteNumber;
        TBuf<9>		iStartTime;
        TBuf<2>		iDirection;
        TBuf<2>		iType;
        TUint32		iDuration;
        TBuf<11>	iDate;
};
 
 
class CMyDBClass : public CBase
{
public : 
    void ConstructL();
    ~CMyDBClass();
public:
   // void DeleteFromDatabaseL(const TDesC& afromDate, const TDesC& atoDate);
    void DeleteFromDatabaseL(const TDesC& afromDate, const TDesC& atoDate);
    void UpdateDatabaseL(const TDesC& aName, const TDesC& aValue, TInt& aIndex);
    void SaveToDatabaseL(const TDesC& myNumber, const TDesC& aRemoteNumber, const TDesC& aStartTime, const TDesC& aDirection, const TDesC& aType, const TUint32& aDuration, const TDesC& aDate);
    void ReadDbItemsL(RArray<TExampleItem>&	aItemArray);
    RArray<TExampleItem> GetDetailsFromDatabaseL(const TDesC& afromDate, const TDesC& atoDate);
private:
    void CreateTableL(RDbDatabase& aDatabase);
private:
    RArray<TExampleItem> iItemArray;
    RDbNamedDatabase iLogDetailsDatabase;
    RFs iFsSession;
};

#endif

